
module.exports = (app)=> { 

  const DataTypes = app.Sequelize;

  return app.model.define('t_dev_state', {

    pdi_index: {
      type: DataTypes.INTEGER.UNSIGNED,
      allowNull: false,
      defaultValue: 0,
      primaryKey: true
    },
    ss_UpdateTime: {
      type: DataTypes.DATE,
      allowNull: false
    },
    ss_DevOfflineState: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: "设备断线状态, 0=在线, 1=离线"
    },
    ss_DevWorkState: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: "设备工作状态, 0=运行, 1=停止 UPS的运行状态为逆变1为电池供电"
    },
    ss_AllWarnNum: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: "该设备告警个数"
    },
    ss_WarnClass1Num: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: "一级告警个数"
    },
    ss_WarnClass2Num: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: "二级告警个数"
    },
    ss_WarnClass3Num: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: "三级告警个数"
    },
    ss_WarnClass4Num: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: "四级告警个数"
    },
    Co_ID: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "企业号"
    },
    AreaId: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "区域"
    }
  }, {
    tableName: 't_dev_state',
    timestamps: false,
    underscored: false,
    indexes: [
      {
        name: "pdi_index",
        unique: true,
        using: "HASH",
        fields: [
          { name: "pdi_index" },
        ]
      },
    ]
  });
};
